package se.cefalo.ceti.gui.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import se.cefalo.ceti.domain.User;

/**
 * Test of validation in Spring.
 */
public class UserValidator implements Validator {
    public boolean supports(Class clazz) {
        return User.class.equals(clazz);
    }

    public void validate(Object target, Errors errors) {
        User user = (User) target;
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "username.required", "name must be supplied");
    }
}
